import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueRouter from 'vue-router'
import ElementUI from 'element-ui';  // 引入组件
import 'element-ui/lib/theme-chalk/index.css'; // 引入样式
import Login from './components/Login'
import Home from './components/Home'
import Product from './components/Product'
import Clothes from './components/Clothes'
import Fresh from './components/Fresh'
import Book from './components/Book'

Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(VueRouter)
Vue.use(ElementUI)



// 配置路由表, 定义一个数组变量routes，名字可以任意取
const routes = [{
  path: '/login',           // 地址
  name: 'login',            // 名字
  component: Login     // 组件
}, {
  path: '/',            // 地址
  name: 'home',             // 名字
  component: Home,     // 组件

  children: [{                // 子路由表
    path: '',
    component: Product
  }, {
    path: 'clothes',
    component: Clothes
  }, {
    path: 'fresh',
    component: Fresh
  }, {
    path: 'book',
    component: Book
  }]
}]

// 初始化VueRouter对象
const router = new VueRouter({
  mode: 'history',     // 路由模式
  routes: routes       // 路由表
})

new Vue({
  render: h => h(App),
  router: router
}).$mount('#app')
